﻿using System.Windows;
using Prism.Commands;
using Prism.Regions;
using YF_Music.Core;
using YF_Music.Core.Events;
using YF_Music.Core.Mvvm;

namespace YF_Music.Modules.APP_My.ViewModels
{
  public class APP_MyViewModel : RegionViewModelBase
  {
    private string _message;
    private readonly PublishCoreEvent _publishEvent;

    public string Message
    {
      get { return _message; }
      set { SetProperty(ref _message, value); }
    }

    public DelegateCommand MyFavoriteMusicList { get; private set; }
    public DelegateCommand NavigationToLocalMusicCommand { get; private set; }


    public APP_MyViewModel(IRegionManager regionManager,PublishCoreEvent publishEvent) :
        base(regionManager)
    {
      
      MyFavoriteMusicList = new DelegateCommand(() =>
      {
        MessageBox.Show("My Favorite Music List Clicked", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
      });

     
      this._publishEvent = publishEvent;
      NavigationToLocalMusicCommand = new DelegateCommand(() =>
      {
        RegionManager.RequestNavigate(RegionNames.ContentRegion, "LocalMusicView");
        //_publishEvent.PublishShowOnlyPlayEvent(true);
      });
    }

    public override void OnNavigatedTo(NavigationContext navigationContext)
    {
      _publishEvent.PublishShowOnlyPlayEvent(false);
    }
    public override void OnNavigatedFrom(NavigationContext navigationContext)
    {
      _publishEvent.PublishShowOnlyPlayEvent(true);
    }
  }
}
